<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>机构管理</title>
	<meta name="decorator" content="default"/>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery-1.9.1.js" type="text/javascript" language="javascript" ></script>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery.media.js" type="text/javascript" language="javascript"  ></script>
	<script type="text/javascript">
		$(document).ready(function() {
            submitFunc();
            $(":checkbox").click(function(){
                if($(this).attr("checked")!=undefined)
                {
                    $(this).siblings().attr("checked",false);
                    $(this).attr("checked",true);
                }
            });
        });

        function selectGroup() {
          var _healthCode=  $('input:radio:checked').val(); //获取checkbox的值
          var _patientId=$('#patientId').val();
            $.ajax({
                type: "get",
                dataType:"json",
                url: "${pageContext.request.contextPath}/a/znjj/patientInfo/updateHealthCode",
                data:{'healthCode':_healthCode,'patientId':_patientId},
                success:function(data){
                    if(data !="" && data.id==1){
                        alert(data.message);
                        window.parent.window.reload();
                        window.parent.window.closeModalDialog();
                    }
                },
                error:function(){
                    alert(data.message);
                }
            });
        }
		function submitFunc(){
            $.ajax({
                type: "get",
                dataType:"json",
                url: "${pageContext.request.contextPath}/a/sys/office/listData?parentId=0c3f57cbf08442cabcf3d8767aa2b6ee",
                success:function(data){
                    if(data !=""){
                        var dom_table = "<table id='treeTable' class='table table-striped table-bordered table-condensed'><thead><tr><th>选择</th><th>机构编码</th><th>机构名称</th></thead><tbody>";
                        var dom_tr = "<tr>";
                        $(data).each(function(index) {
                            var val = data[index];
                                    dom_tr+="<td><input type='radio' id='"+index+"' name='radio_code' value='"+val.code+"'/></td>";
                                    dom_tr+="<td>"+val.name+"</td>";
                                    dom_tr+="<td>"+val.code+"</td>";
                                    dom_tr+="</tr>";
                        });
                        dom_tr+="<tr><td  style='text-align: center' colspan='3'><a  href='#' role='button' class='btn btn-primary' onclick='selectGroup();'>确定</a></td></tr>";
                       dom_table += dom_tr+"</tbody></table>";
                        $("#div1").append(dom_table);
                    }else{
                       // $("#pdfplay").html("没有心电图！");
                    }
                },
                error:function(){
                    alert("系统出现问题");
                }
            });
		}

	</script>
</head>
<body>
<input id="patientId" name="patientId" type="hidden" value="${patientId}"/>
    <div id="div1" ></div>
</body>
</html>